﻿<phone:PhoneApplicationPage
    x:Class="Knihotoc_WP8.Pages.BookListPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:customControls="clr-namespace:Knihotoc_WP8.CustomControls"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">

    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="groupHeaderTemplate">
            <Border Background="{Binding Source={StaticResource CurrentSettings}, Path=ForegroundColor, Mode=TwoWay}" 
                    Margin="6">
                <TextBlock Text="{Binding Title}" 
                           FontSize="40" 
                           Foreground="{Binding Source={StaticResource CurrentSettings}, Path=BackgroundColor, Mode=TwoWay}" />
            </Border>
        </DataTemplate>
        
        <DataTemplate x:Key="bookItemTemplate">                
                <TextBlock Grid.Row="0"
                               Grid.Column="1"
                               TextWrapping="NoWrap"
                               FontSize="40"
                               Text="{Binding Title}" />
        </DataTemplate>
        
        <Style x:Key="LongListSelectorJumpListStyle" TargetType="phone:LongListSelector">
            <Setter Property="GridCellSize" Value="113, 113" />
            <Setter Property="LayoutMode" Value="Grid" />
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Border Background="{Binding Source={StaticResource CurrentSettings}, Path=ForegroundColor, Mode=TwoWay}"
                                Width="113" Height="113" Margin="6">
                            <TextBlock Text="{Binding Title}"
                                       FontSize="48"
                                       Padding="6"
                                       Foreground="{Binding Source={StaticResource CurrentSettings}, Path=BackgroundColor, Mode=TwoWay}"
                                       VerticalAlignment="Center" />
                        </Border>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="{Binding Source={StaticResource CurrentSettings}, Path=BackgroundColor, Mode=TwoWay}">

        <controls:Pivot Title="{Binding ConverterParameter=ApplicationTitle, Converter={StaticResource LocalizedStrings}, Source={StaticResource LocalizedStrings}}">
            <!--Pivot item one-->
            <controls:PivotItem Header="{Binding ConverterParameter=FoundBooksListTitle, Converter={StaticResource LocalizedStrings}, Source={StaticResource LocalizedStrings}}">
                <Grid x:Name="foundBooksGrid" Margin="12,0,12,0">
                    <phone:LongListSelector x:Name="foundBooksLongListSelector"
                                            ItemTemplate="{StaticResource bookItemTemplate}"
                                            GroupHeaderTemplate="{StaticResource groupHeaderTemplate}"
                                            JumpListStyle="{StaticResource LongListSelectorJumpListStyle}"
                                            IsGroupingEnabled="True"
                                            LayoutMode="List"
                                            HideEmptyGroups="False"/>
                </Grid>
            </controls:PivotItem>

            <!--Pivot item two-->
            <controls:PivotItem Header="{Binding ConverterParameter=AddedBooksListTitle, Converter={StaticResource LocalizedStrings}, Source={StaticResource LocalizedStrings}}">
                <Grid x:Name="addedBooksGrid" Margin="12,0,12,0">
                    <phone:LongListSelector x:Name="addedBooksLongListSelector"
                                            ItemTemplate="{StaticResource bookItemTemplate}"
                                            GroupHeaderTemplate="{StaticResource groupHeaderTemplate}"
                                            IsGroupingEnabled="True"
                                            LayoutMode="List" />
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="findBookButton" 
                                            Click="FindBookButton_Click" 
                                            IconUri="/Images/AppbarIcons/appbar.add.rest.png" 
                                            Text="Button 1" />
            <shell:ApplicationBarIconButton x:Name="settingsApplicationBarButton" 
                                            Click="SettingsApplicationBarButton_Click" 
                                            IconUri="/Images/AppbarIcons/appbar.feature.settings.rest.png" 
                                            Text="Button 2" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>